// (function () {
//     const str = document.querySelector('#str')
//       function getPageName() {
//         const pathArr = location.pathname.split('/')
//         return pathArr[pathArr.length - 1]
      
//       }
//     if(getPageName() == 'blog-single.html'){
//       let arr = [''];
//       arr = str;
//       for(i=0;i<arr.length;i++){
        
//       }
//     }
    
    
    
    
    
//     })();
const size = document.querySelector('.size');
const url = 'https://www.fastmock.site/mock/f76dce7c6062441d9a218a5dd3ea37fa/size/size'
axios.get(url).then(function (response) {
    let blogs = response.data.data;
    size.insertAdjacentHTML('afterbegin', `
    <div >
              <p>${blogs.desc} </p>
          </div>
          <div class="flex justify-content">
              <img class="pictures" src="./images/bdc2fb559b324259a3d4bbfd0962cf60@2x.png" alt="">
          </div>
          <div>
              <p>${blogs.desc}</p>
          </div>
`);
});



let message = document.querySelector('.Message')
let btnIssue = document.querySelector('#release');
    btnIssue.addEventListener('click', function () {
        let nameInput = document.querySelector('#name-input');
        let emailInput = document.querySelector('#email-input');
        let contentTextarea = document.querySelector('#lastInput');
        let time = getNowFormatDate();
        axios.post('http://81.70.162.221:3000/postComment',
            {
                name: nameInput.value,
                email: emailInput.value,
                content: contentTextarea.value,
                messageId: Math.random().toString().substring(2),
                time:time
            }
        ).then(function (res) {
            if (res.data == 'success') {
                let arr = JSON.parse(res.config.data);
                console.log(arr)
                message.insertAdjacentHTML('afterbegin', `
                <div class="content">
                <img src="./images/e05c709d2b1d79cdd1ddfc1a6a25548.jpg" alt="">
                    <span class="message-name">${arr.name}</span>
                    <span class="message-date">${arr.time}</span>
                    <p class="message-content">
                        ${arr.content}
                    </p >
                </div>
                `);
                nameInput.value='';
                emailInput.value='';
                contentTextarea.value='';
            }
        });
    }, false);
    
    
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }